﻿using System;
using System.Net;
using System.Net.Sockets;
using System.Text;

namespace Echo
{
	class Program
	{

		static void Main() {

			UdpClient client;
			IPEndPoint local;
			IPEndPoint remote = null;

			int port = 2078;

			local = new IPEndPoint( IPAddress.Any, 2079 );
			client = new UdpClient( local );

			Console.WriteLine(DateTime.Now);

			while (true) {
				try {
					byte[ ] msg = client.Receive( ref remote );

					if (msg.Length == 0)
						continue;
					else {
						string s = Encoding.ASCII.GetString( msg );
						Console.WriteLine(s);
						client.Send(msg , msg.Length,remote );
					}
				}
				catch (Exception) { throw; }


			}
		}
	}
}
